package com.icehand.disruptor.starter.context;

import com.icehand.disruptor.starter.event.DisruptorApplicationEvent;
import com.icehand.disruptor.starter.event.DisruptorEvent;
import com.icehand.disruptor.starter.publisher.DisruptorEventPublisher;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 *
 * @author zhoujunmei
 * @date 2019-07-31 17:31
 * @remark
 */
public class DisruptorApplicationContext implements ApplicationContextAware, DisruptorEventPublisher {
    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    @Override
    public void publishEvent(DisruptorEvent disruptorEvent) {
        applicationContext.publishEvent(new DisruptorApplicationEvent(disruptorEvent));
    }
}
